﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;
namespace BUS
{
    public class ChuyenBay_BUS
    {
        #region Cac ham truy xuat du lieu
        public static List<ChuyenBay_DTO> layDanhSachChuyenBay()
        {
            return ChuyenBay_DAO.layDanhSachChuyenBay();
        }

        //dung de xuat la list machuyen chuyen bay trong lich bay dang mo nhung chua bay
        //cho ng chon khi them ve
        public static List<ChuyenBay_DTO> layDanhSachChuyenBayDangMoLich()
        {
            return ChuyenBay_DAO.layDanhSachChuyenBayDangMoLich();
        }

        public static List<ChuyenBay_DTO> layChuyenBayTheoSanBayDi(string sbDi)
        {
            return ChuyenBay_DAO.layChuyenBayTheoSanBayDi(sbDi);
        }

        public static List<ChuyenBay_DTO> layChuyenBayTheoSanBayDen(string sbDen)
        {
            return ChuyenBay_DAO.layChuyenBayTheoSanBayDen(sbDen);
        }

        public static List<ChuyenBay_DTO> layChuyenBayTheoSanBayTGian(string sbtg)
        {
            return ChuyenBay_DAO.layChuyenBayTheoSanBayTGian(sbtg);
        }

        #endregion

        #region Cac ham tuong tac voi co so du lieu
        public static int themChuyenbay(ChuyenBay_DTO chuyenBay)  //them chuyen bay
        {
            //kiem tra xem du lieu co ton tai chua
            if (ChuyenBay_DAO.ktTonTaiChuyenBay(chuyenBay.maCB) == true)
                return 2;

            //kiem tra xem thoi gian bay co hop le quy dinh khong 
            if (ChuyenBay_DAO.ktThoiGianBayMinHopLe(chuyenBay) == false)
                return 3;

            if (ChuyenBay_DAO.themChuyenbay(chuyenBay) == true)
                return 1;

            return 0;

        }

        public static bool suaChuyenBay(ChuyenBay_DTO chuyenBay)      // sua chuyenbooly
        {
            //neu sua chuyen bay ma thoi gian bay min khong hop le thi khong cho sua
            if (ChuyenBay_DAO.ktThoiGianBayMinHopLe(chuyenBay) == false)
                return false;

            return ChuyenBay_DAO.suaChuyenBay(chuyenBay);
        }

        public static bool xoaChuyenBay(string chuyenBay)      // coa chuyen bay
        {
            return ChuyenBay_DAO.xoaChuyenBay(chuyenBay);
        }
        #endregion

    }
}
